// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate apps_script_type;
extern crate bytes;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Docs add-on manifest.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DocsAddOnManifest {
    /// If present, this overrides the configuration from
    /// `addOns.common.homepageTrigger`.
    pub homepage_trigger: std::option::Option<apps_script_type::model::HomepageExtensionPoint>,

    /// Endpoint to execute when file scope authorization is granted
    /// for this document/user pair.
    pub on_file_scope_granted_trigger: std::option::Option<crate::model::DocsExtensionPoint>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DocsAddOnManifest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [homepage_trigger][crate::model::DocsAddOnManifest::homepage_trigger].
    pub fn set_homepage_trigger<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<apps_script_type::model::HomepageExtensionPoint>,
    {
        self.homepage_trigger = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [homepage_trigger][crate::model::DocsAddOnManifest::homepage_trigger].
    pub fn set_or_clear_homepage_trigger<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<apps_script_type::model::HomepageExtensionPoint>,
    {
        self.homepage_trigger = v.map(|x| x.into());
        self
    }

    /// Sets the value of [on_file_scope_granted_trigger][crate::model::DocsAddOnManifest::on_file_scope_granted_trigger].
    pub fn set_on_file_scope_granted_trigger<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::DocsExtensionPoint>,
    {
        self.on_file_scope_granted_trigger = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [on_file_scope_granted_trigger][crate::model::DocsAddOnManifest::on_file_scope_granted_trigger].
    pub fn set_or_clear_on_file_scope_granted_trigger<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<crate::model::DocsExtensionPoint>,
    {
        self.on_file_scope_granted_trigger = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for DocsAddOnManifest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.apps.script.type.docs.DocsAddOnManifest"
    }
}

/// Common format for declaring a Docs add-on's triggers.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DocsExtensionPoint {
    /// Required. The endpoint to execute when this extension point is activated.
    pub run_function: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DocsExtensionPoint {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [run_function][crate::model::DocsExtensionPoint::run_function].
    pub fn set_run_function<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.run_function = v.into();
        self
    }
}

impl wkt::message::Message for DocsExtensionPoint {
    fn typename() -> &'static str {
        "type.googleapis.com/google.apps.script.type.docs.DocsExtensionPoint"
    }
}
